<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Outputting measurements - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.measure.output.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.measure.output.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.measure.creation.html">Creation of Measurements</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.measure.html">Zend_Measure</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.measure.edit.html">Manipulating Measurements</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.measure.output" class="section"><div class="info"><h1 class="title">Outputting measurements</h1></div>

    

    <p class="para">
        Measurements can be output in a number of different ways.
    </p>

    <p class="para">
        <a href="zend.measure.output.html#zend.measure.output.auto" class="link">Automatic output</a>
    </p>

    <p class="para">
        <a href="zend.measure.output.html#zend.measure.output.value" class="link">Outputting values</a>
    </p>

    <p class="para">
        <a href="zend.measure.output.html#zend.measure.output.unit" class="link">Output with unit of measurement</a>
    </p>

    <p class="para">
        <a href="zend.measure.output.html#zend.measure.output.unit" class="link">Output as localized string</a>
    </p>

    <div class="section" id="zend.measure.output.auto"><div class="info"><h1 class="title">Automatic output</h1></div>
        

        <p class="para">
            <span class="classname">Zend_Measure</span> supports outputting of strings automatically.

            <div class="example" id="zend.measure.output.auto.example-1"><div class="info"><p><b>Example #1 Automatic output</b></p></div>
                

                <pre class="programlisting brush: php">
$locale = new Zend_Locale(&#039;de&#039;);
$mystring = &quot;1.234.567,89&quot;;
$unit = new Zend_Measure_Length($mystring,
                                Zend_Measure_Length::STANDARD,
                                $locale);

echo $unit;
</pre>

            </div>
        </p>

        <blockquote class="note"><p><b class="note">Note</b>: <span class="info"><b>Measurement output</b><br /></span>
            

            <p class="para">
                Output can be achieved simply by using
                <a href="http://php.net/echo" class="link external">&raquo; echo</a> or
                <a href="http://php.net/print" class="link external">&raquo; print</a>.
            </p>
        </p></blockquote>
    </div>

    <div class="section" id="zend.measure.output.value"><div class="info"><h1 class="title">Outputting values</h1></div>
        

        <p class="para">
            The value of a measurement can be output using  <span class="methodname">getValue()</span>.

            <div class="example" id="zend.measure.output.value.example-1"><div class="info"><p><b>Example #2 Output a value</b></p></div>
                

                <pre class="programlisting brush: php">
$locale = new Zend_Locale(&#039;de&#039;);
$mystring = &quot;1.234.567,89&quot;;
$unit = new Zend_Measure_Length($mystring,
                                Zend_Measure_Length::STANDARD,
                                $locale);

echo $unit-&gt;getValue();
</pre>

            </div>
        </p>

        <p class="para">
            The  <span class="methodname">getValue()</span> method accepts an optional parameter
            <span class="property">round</span> which allows to define a precision for the generated
            output. The standard precision is &#039;2&#039;.
        </p>
    </div>

    <div class="section" id="zend.measure.output.unit"><div class="info"><h1 class="title">Output with unit of measurement</h1></div>
        

        <p class="para">
            The function  <span class="methodname">getType()</span> returns the current unit of measurement.

            <div class="example" id="zend.measure.output.unit.example-1"><div class="info"><p><b>Example #3 Outputting units</b></p></div>
                

                <pre class="programlisting brush: php">
$locale = new Zend_Locale(&#039;de&#039;);
$mystring = &quot;1.234.567,89&quot;;
$unit = new Zend_Measure_Weight($mystring,
                                Zend_Measure_Weight::POUND,
                                $locale);

echo $unit-&gt;getType();
</pre>

            </div>
        </p>
    </div>

    <div class="section" id="zend.measure.output.localized"><div class="info"><h1 class="title">Output as localized string</h1></div>
        

        <p class="para">
            Outputting a string in a format common in the users&#039; country is usually desirable. For
            example, the measurement &quot;1234567.8&quot; would become &quot;1.234.567,8&quot; for Germany. This
            functionality will be supported in a future release.
        </p>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.measure.creation.html">Creation of Measurements</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.measure.html">Zend_Measure</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.measure.edit.html">Manipulating Measurements</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.measure.html">Zend_Measure</a></li>
  <li><a href="zend.measure.introduction.html">Introduction</a></li>
  <li><a href="zend.measure.creation.html">Creation of Measurements</a></li>
  <li class="active"><a href="zend.measure.output.html">Outputting measurements</a></li>
  <li><a href="zend.measure.edit.html">Manipulating Measurements</a></li>
  <li><a href="zend.measure.types.html">Types of measurements</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>